home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Sample Code / Newton Sample Code 1.2 / Proto Templates / Keys-3 / Keys.text < prev    next >
Encoding:
Text File  |  1994-03-11  |  3.6 KB  |  134 lines  |  [TEXT/MPS ]

  1. // Copyright © 1993-94 Apple Computer, Inc. All rights reserved.
  2.  
  3. constant kAppSymbol := '|Keys:PIEDTS|;
  4.  
  5. // first open the resrouce file containing the picture
  6. // that I want. NOTE: you must use a full Macintosh
  7. // pathname for the file. the 'home' constant represents
  8. // your project file path.
  9. r := OpenResFileX(home&"pictures");
  10.  
  11. // now read in the picture and assign it to a variable
  12. // the second argument says not to generate a mask
  13. planet_Picture := GetPictAsBits("Planet", nil);
  14. TARDIS_Picture := GetPictAsBits("TARDIS", nil);
  15.  
  16. // then close the resource file
  17. CloseResFileX(r);
  18.  
  19. // ---- End Project Data ----
  20.  
  21.  
  22. // ---- File keyfun ----
  23. myBase :=
  24.    {title: "KeyFun",
  25.     viewBounds: {top: 0, left: 0, right: 240, bottom: 336},
  26.     viewSetupFormScript:
  27.       func()
  28.       begin
  29.           constant kMaxWidth := 240;
  30.           constant kMaxHeight := 336;
  31.       
  32.           local b := GetAppParams();
  33.       
  34.           viewBounds := RelBounds(b.appAreaLeft, b.appAreaTop,
  35.                                                   Min(b.appAreaWidth, kMaxWidth),
  36.                                                   Min(b.appAreaHeight, kMaxHeight)
  37.                                               );
  38.       end,
  39.     _proto: protoApp,
  40.     debug: "myBase"
  41.    };
  42.  
  43. _view000 := /* child of myBase */
  44.    {text: "Toggle Keyboard",
  45.     buttonClickScript:
  46.       func()
  47.       begin
  48.          // if the keyboard is not open, set the current
  49.          // key view to the paragraph view (paraView).
  50.          // the key view is where the strings or characters
  51.          // associated with a keypress will be sent/shown
  52.          if not Visible(myKeyboard) then
  53.             SetKeyView(paraView, StrLen(paraView.text));
  54.            
  55.          myKeyboard:Toggle();
  56.       end,
  57.     viewBounds: {left: 63, top: 17, right: 165, bottom: 39},
  58.     _proto: protoTextButton
  59.    };
  60.  
  61.  
  62.  
  63. myKeyboard := /* child of myBase */
  64.    {viewBounds: {left: 3, top: 49, right: 215, bottom: 149},
  65.     _proto: protoKeyboard,
  66.     debug: "myKeyboard"
  67.    };
  68. // View myKeyboard is declared to myBase
  69.  
  70. _view001 := /* child of myKeyboard */
  71.    {
  72.     keyDefinitions:
  73.       [[keyVUnit, keyVUnit,
  74.                       planet_Picture,  "Gallifrey ",        keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3,
  75.                       TARDIS_Picture,  "TARDIS! ",        keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3],
  76.        [keyVUnit, keyVUnit,
  77.                       ["One ", "TWO! "],  ["One ", "TWO! "],        keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3,
  78.                       $b,  func() begin 
  79.                               :toggleCharacter(); 
  80.                               return $b; end; ,        keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3]
  81.                   ],
  82.     viewBounds: {left: 4, top: 7, right: 204, bottom: 79},
  83.     keyArrayIndex: 0,
  84.     toggleCharacter:
  85.       func()
  86.       begin
  87.       if (self.keyArrayIndex = 0) then
  88.           SetValue(self, 'keyArrayIndex, 1);
  89.       else
  90.           SetValue(self, 'keyArrayIndex, 0);
  91.       end,
  92.     viewFormat: 0,
  93.     _proto: protoKeypad
  94.    };
  95.  
  96. // After Script for "_view001"
  97. thisView := _view001;
  98. //Set the saveBounds to the viewBounds since this is probably what you want
  99. thisView.saveBounds := Clone(thisView.viewBounds);
  100.  
  101.  
  102.  
  103. _view002 := /* child of myKeyboard */ {_proto: protoClosebox};
  104.  
  105.  
  106.  
  107. // After Script for "myKeyboard"
  108. thisView := myKeyboard;
  109. //Set the saveBounds to the viewBounds since this is probably what you want
  110. thisView.saveBounds := Clone(thisView.viewBounds);
  111.  
  112.  
  113.  
  114. paraView := /* child of myBase */
  115.    {viewFlags: 1,
  116.     viewFormat: 12625,
  117.     viewlinespacing: 20,
  118.     viewFont: 18434,
  119.     viewBounds: {left: 11, top: 160, right: 233, bottom: 283},
  120.     text: "",
  121.     viewclass: 81,
  122.     debug: "paraView"
  123.    };
  124. // View paraView is declared to myBase
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132. // ---- Beginning of section for non used Layout files ----
  133.  
  134. // End of output